Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made many changes:
I made the script consider all links in the page, not only those that are in the specialized "Reflinks" section. This is much closer to how Roam Research works.
I made the forward-link scanner look not only at the specified collection, but recursively inside, including inside subpages, and really inside any page that can be reached from the specified collection. IMPORTANT NOTE: the new code will go outside of just the specified collection -- into any page that is reachable from the original collection (and potentially into all pages that can be edited by the user). thus, this script is more risky than the original version! (But more powerful.)
I changed the added banklinks to be URL-links, rather than page-links. This is useful, since each page-link can only appear once on any given page, so a page-link couldn't appear both in the main page and in the backlinks section. But now, with URL-links, a page can be linked more than once. I would have loved to make the links @mention links to pages (like the ones you get when you press @ in notion and create a link) but I don't know how to generate these in the API
I added context to backlinks: the banklink now gives the contents of the block where the forward-link was found.
Overall, this script achieves functionality that is reminiscent of Roam Research.
This also satisfies feature request #1